package outros;

import java.sql.Connection;
import java.sql.DriverManager;
import javax.swing.JOptionPane;

public class Conexao {
    private String status = "";
    private Connection con;

    public Conexao() {
    }

    public void abrirConexao() {
        try {
            Class.forName("org.postgresql.Driver");
            con = DriverManager.getConnection("jdbc:postgresql://10.239.39.6:5432/db_patrimonio", "postgres", "postgres");
            status = "ok";
        } catch (Exception e){
            status = "Erro ao tentar conectar ao banco de dados. Detalhes: "+e.getMessage();
            JOptionPane.showMessageDialog(null, status);
        }
    }

    public void fecharConexao() {
        try {
            con.close();
        } catch (Exception e) {
        }
    }

    public Connection getConexao(){
        return con;
    }

    public String getStatus(){
        return status;
    }
}
